<extend name="Public/base"/>

<block name="body">
  <!-- 标题 -->
  <div class="main-title">
    <h2>优惠券管理({$_total})</h2>
  </div>

  <!-- 按钮工具栏 -->
  <div class="cf">
    <div class="search-form fr cf">
      <input type="text" name="store" class="search-input w-260" value="{:I('store')}" placeholder="店铺名称">
      <a class="sch-btn" href="javascript:;" id="search" url="{:U()}"><i class="btn-search"></i></a>
    </div>

  </div>
  
  <!-- 数据表格 -->
  <div class="data-table">
    <table>
      <thead>
        <tr>
          <!-- <th class="row-selected row-selected"><input class="check-all" type="checkbox"/></th> -->
          <th>优惠券编号</th>
          <th>优惠券名称</th>
          <th>优惠券数量</th>
          <th>优惠券金额</th>
          <th>适用商品</th>
          <th>适用限额</th>
          <th>添加时间</th>
          <th>有效日期</th>
          <th>是否前台展示</th>
          <th>优惠券来源</th>
          <th width="185">操作</th>
        </tr>
      </thead>
      <tbody>
        <notempty name="list">
          <volist name="list" id="vo">
            <tr class="status_trclass_{$vo.status}">
              <!-- <td><input class="ids" type="checkbox" name="ids[]" value="{$vo.id}" /></td> -->
              <eq name="vo.store_id" value="0">
                <td><a href="{:U('edit?id='.$vo['id'])}">{$vo['number']}</a></td>
                <td><a href="{:U('edit?id='.$vo['id'])}">{$vo['name']}</a></td>
              <else />
                <td><a href="javascript:;">{$vo['number']}</a></td>
                <td><a href="javascript:;">{$vo['name']}</a></td>
              </eq>
                <td><a href="{:U('CouponUser/index?id='.$vo['id'])}">{$vo['num']}</a></td>
              <td>{$vo['amount']}</td>
              <td>
                <notempty name="vo.items"><a href="javascript:showItems('{$vo['items']}');">点击查看</a><else/>全场通用</notempty>
              </td>
              <td>购物满{$vo['norm']}元</td>
              <td>{$vo['create_time']|time_format}</td>
              <td <eq name="vo.is_expire" value="1">class="date-expired"</eq>>{$vo.expire_time|time_format='Y-m-d H:i:s'}</td>
              <td> <eq name='vo.is_show' value='1'>是 <else /> 否</eq></td>
              <php>$member_id = get_store_member_id($vo['store_id']);</php>
              <td><gt name="member_id" value="0"><a href="{:U('Store/detail?member_id='.$member_id)}">{:store_name($vo['store_id'])}</a><else />{:store_name($vo['store_id'])}</gt></td>
              <eq name="vo.store_id" value="0">
                <td width="240">
                  <a href="{:U('edit?id='.$vo['id'])}">[编辑]</a>
                  <a href="{:U('setStatus?ids='.$vo['id'].'&status='.abs(1-$vo['status']))}" class="ajax-get">[{$vo.status_text}]</a>
                  <!-- <eq name="vo.is_expire" value="0">
                    <a href="{:U('CouponUser/add?id='.$vo['id'])}">[发放]</a>
                  <else/>
                    <span class="disabled">[发放]</span>
                  </eq> -->
                  <a href="{:U('del?ids='.$vo['id'])}" class="confirm ajax-get">[删除]</a>
                  <!-- <neq name="vo.num" value="0"><a target="_blank" href="{:U('Coupon/export?id='.$vo['id'])}">[导出]</a><else /> <span class="disabled">[导出]</span></neq> -->
                </td>
              <else />
                <td width="240">
                  <span class="disabled">[编辑]</span>
                  <span class="disabled">[{$vo.status_text}]</span>
                  <!-- <span class="disabled">[发放]</span> -->
                  <span class="disabled">[删除]</span>
                  <!-- <neq name="vo.num" value="0">
                    <a target="_blank" href="{:U('Coupon/export?id='.$vo['id'])}">[导出]</a>
                  <else /> 
                    <span class="disabled">[导出]</span>
                  </neq> -->
                  <a href="{:U('CouponUser/index?id='.$vo['id'])}">领取记录</a>
                </td>
              </eq>
            </tr>
          </volist>
        <else/>
          <tr><td colspan="9" class="text-center"> 暂无优惠券!  <!-- <a href="{:U('Coupon/add')}" class="btn btn-mini">&plus;立即添加</a> --></td></tr>
        </notempty>
      </tbody>
    </table> 
  </div>

  <!-- 分页 -->
  <div class="page">
    {$_page}
  </div>
</block>
<block name="script">
    <script type="text/javascript">
        $(function(){
            //搜索功能
            $("#search").click(function(){
                var url = $(this).attr('url');
                var query  = $('.search-form').find('input').serialize();
                if(url.indexOf('?')>0){
                    url += '&' + query;
                }else{
                    url += '?' + query;
                }
                window.location.href = url;
            });

            //回车自动提交
            $('.search-form').find('input').keyup(function(event){
                if(event.keyCode===13){
                    $("#search").click();
                }
            });

            //设置单选，复选，下拉菜单的值
            Core.setValue('delivery_corp', '{$delivery_corp|default = ""}');

            //导航高亮
            highlight_subnav("{:U('index')}");
        });
    </script>
</block>